#include "led.h"

static void LED_On(uint8_t  IS_LED);
static void LED_Off(uint8_t  IS_LED);
static void LED_Toggle(uint8_t IS_LED);

#define LED_ON GPIO_PIN_RESET
#define LED_OFF GPIO_PIN_SET

LED_TypeDef LED = {LED_On, LED_Off, LED_Toggle};

static void LED_On(uint8_t IS_LED)
{
    switch (IS_LED)
    {
    case LED_G:
        HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, LED_ON);
        break;
    case LED_B:
        HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, LED_ON);
        break;
    case LED_R:
        HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, LED_ON);
        break;
    case LED_ALL:
        HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, LED_ON);
        HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, LED_ON);
        HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, LED_ON);
        break;
    default:
        break;
    }
}
static void LED_Off(uint8_t IS_LED)
{
    switch (IS_LED)
    {
    case LED_G:
        HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, LED_OFF);
        break;
    case LED_B:
        HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, LED_OFF);
        break;
    case LED_R:
        HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, LED_OFF);
        break;
    case LED_ALL:
        HAL_GPIO_WritePin(LED_G_GPIO_Port, LED_G_Pin, LED_OFF);
        HAL_GPIO_WritePin(LED_B_GPIO_Port, LED_B_Pin, LED_OFF);
        HAL_GPIO_WritePin(LED_R_GPIO_Port, LED_R_Pin, LED_OFF);
        break;
    default:
        break;
    }
}
static void LED_Toggle(uint8_t IS_LED)
{
    switch (IS_LED)
    {
    case LED_G:
        HAL_GPIO_TogglePin(LED_G_GPIO_Port, LED_G_Pin);
        break;
    case LED_B:
        HAL_GPIO_TogglePin(LED_B_GPIO_Port, LED_B_Pin);
        break;
    case LED_R:
        HAL_GPIO_TogglePin(LED_R_GPIO_Port, LED_R_Pin);
        break;
    case LED_ALL:
        HAL_GPIO_TogglePin(LED_G_GPIO_Port, LED_G_Pin);
        HAL_GPIO_TogglePin(LED_B_GPIO_Port, LED_B_Pin);
        HAL_GPIO_TogglePin(LED_R_GPIO_Port, LED_R_Pin);
        break;
    default:
        break;
    }
}

